﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Novell.DirectoryServices.Linq
{
    /// <summary>
    /// Specifies the directory schema to query.
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")
    , AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    public sealed class DirectorySchemaAttribute : Attribute
    {
        #region Constructors
        /// <summary>
        /// Creates a new schema indicator attribute.
        /// </summary>
        /// <param name="schema">Name of the schema to query for.</param>
        public DirectorySchemaAttribute(string schema)
            : this(schema, false)
        { }
        /// <summary>
        /// Creates a new schema indicator attribute.
        /// </summary>
        /// <param name="schema">Name of the schema to query for.</param>
        /// <param name="primary">Use this class as the primary class for objects</param>
        public DirectorySchemaAttribute(string schema, bool primary)
            : this(schema, primary, true)
        { }
        /// <summary>
        /// Creates a new schema indicator attribute.
        /// </summary>
        /// <param name="schema">Name of the schema to query for.</param>
        /// <param name="primary">Use this class as the primary class for objects</param>
        /// <param name="search">Use this class when searching for objects, the default value for New also uses this value</param>
        public DirectorySchemaAttribute(string schema, bool primary, bool search)
            : this(schema, primary, search, search)
        { }
        /// <summary>
        /// Creates a new schema indicator attribute.
        /// </summary>
        /// <param name="schema">Name of the schema to query for.</param>
        /// <param name="primary">Use this class as the primary class for objects</param>
        /// <param name="search">Use this class when searching for objects</param>
        /// <param name="useForNew">Use this class when creating new objects</param>
        public DirectorySchemaAttribute(string schema, bool primary, bool search, bool useForNew)
        {
            Schema = schema;
            Primary = primary;
            Search = search;
            New = useForNew;
        }
        #endregion

        #region Properties

        /// <summary>
        /// Name of the schema to query for.
        /// </summary>
        public string Schema { get; private set; }

        /// <summary>
        /// Specifies if this schema class should be added when creating an object.
        /// </summary>
        public bool New { get; private set; }
        /// <summary>
        /// Specifies if this is the primary schema class to use when querying for object.
        /// This is also used as the structuralObjectClass with OpenLDAP
        /// </summary>
        public bool Primary { get; private set; }

        /// <summary>
        /// Specifies if this schema should be used when searching for the object.
        /// </summary>
        public bool Search { get; private set; }

        ///// <summary>
        ///// Specifies the attributes that are required to create this object.
        ///// OpenLDAP appears to require you to add the structural object class first
        ///// Then you can add the other object classes and attributes.
        ///// You only need to specify the requiredAttributes on the primary schema class.
        ///// </summary>
        //public string[] RequiredAttributes { get; private set; }
        #endregion
    }
}
